package com.coolingme.general;

/**
 * 装饰器模式测试
 *
 * @author wangyue
 * @date 2020-09-15 22:53
 */
public class Client {

    public static void main(String[] args) {
        // 创建需要被装饰的对象
        Component component = new ComponentConcrete();

        // 给对象透明的添加功能A
        Decorator decoratorA = new DecoratorConcreteA(component);
        decoratorA.operation();

        System.out.println("---------------------");

        // 给对象透明的添加功能B
        Decorator decoratorB = new DecoratorConcreteB(component);
        decoratorB.operation();

        System.out.println("---------------------");

        // 装饰器也可以装饰具体的装饰器对象，就相当于在对象增加A功能的基础上，再添加B功能
        Decorator decoratorAB = new DecoratorConcreteB(decoratorA);
        decoratorAB.operation();

    }


}
